import request from './request'

export const fileApi = {
  // 上传文件
  uploadFile(file, receiverId, username) {
    const formData = new FormData()
    formData.append('file', file)
    formData.append('receiverId', receiverId)
    formData.append('username', username)
    
    return request.post('/files/upload', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  // 下载文件
  downloadFile(fileUrl) {
    return request.get(fileUrl, {
      responseType: 'blob'
    })
  },

  // 删除文件
  deleteFile(dateDir, filename) {
    return request.delete(`/files/${dateDir}/${filename}`)
  }
} 